package com.hll.api.config.mybatis;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * mybatis-plus配置
 *
 * @author 何龙
 */
@EnableTransactionManagement
@Configuration
@MapperScan("com.**.mapper")
public class MybatisPlusConfig {

    /**
     * SQL执行效率插件
     */
    @Bean
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor pfi =
                new PerformanceInterceptor();
        //开启SQL格式化
        pfi.setFormat( true );
        return pfi;
    }

    /**
     * mybatis-plus分页插件注册
     */
    @Bean
    public PaginationInterceptor paginationinterceptor() {
        PaginationInterceptor page;
        page = new PaginationInterceptor();
        page.setDialectType( "mysql" );
        return page;
    }
}
